home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-17 | 15.9 KB | 451 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: PixelPaintPro.vu
- #
- # Contains: Quick look test script for PixelPaint Pro version 2.0.1
- #
- # Written by: Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
- #
- # Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.0.8> 12/13/93 KTA Added global gCustomRetrievedDoc := [window
- # t:/@•@-{gBuildVers}≈/], so OpenFile TCS wouldn't fail.
- # <1.0.7> 9/30/93 KTA Initialize gFileName prior to gApptitle being updated by
- # launchTwitch().
- # <1.0.6> 9/28/93 KTA Added returnVal for ModifyDocument hook.
- # <1.0.3> 7/19/93 KTA Updates for FindWindow() to handle descriptors.
- # <1.0.2> 6/16/93 NAGA Renaming InitGlobals(ScriptLevel)to InitGlobals(ScriptLevel)
- # <1+> 5/25/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
-
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "Output.Lib", "DoTasks.Lib","Draw.Lib","UserInterface.Lib","DA.Lib", "Font.Lib", "Globals.Lib", "LaunchQuit.Lib", "TCS.Lib";
-
-
- #########################################################################
- ######## Application Specific Tasks
- #########################################################################
-
- #########################################################################
- # InitAppGlobals()
- #========================================================================
- # Author: GS
- # Description: Sets up tools and fonts for PixelPaint Pro. This task
- # must be called first.
- # Parameters: None
- # Returns: Nothing
- # Examples: InitAppGlobals()
- #========================================================================
- # History:
- #
- ########################################################################
- task InitAppGlobals()
- begin
-
- logstr("setting up {global gApptitle}'s globals");
- global kClick, kDrag, kDragClick, kMultiDrag, kMultiClickDrag, kMultiClick;
- global kPalDocWind, kPalWind, kPullOffPal, kPopUpPal, kScrollPal, gTextStr;
-
- global gWindowInset := {0,43,20,20};
-
- global kToolPaletteNum := 1;
- global kColorPaletteNum := 2;
- global kPatternPaletteNum := 3;
- global kLinePaletteNum := 4;
-
- global gPaletteList := {
- {
- {'≠Full≠',11}, #Main Tool Matrix (Pallete #1)
- kPalWind,
- {3,8}, #tool matrix
- {30,22} #tool offset
- },
-
- {
- {57,274, 86,260,'≠Full≠'}, #Color popup (Pallete #2)
- kPopUpPal,
- {16,16},
- { 9,9}
- },
-
- {
- {60,204, 85,192,'≠Full≠'}, #Pattern popup (Pallete #3)
- kPopUpPal,
- {5,5},
- {20,20}
- },
-
- {
- {61,227, 89,228, '≠Full≠'}, #Lines (Pallete #4)
- kPopUpPal,
- {8,8},
- {11,11}
- }
- };
-
- ### Palette Elements:= Tool#, Pal#, ToolName, ToolType, DblClktoEnd SetAttributes
- global FreeSelectTool := { 1, 1, "FreeSelect", kMultiDrag, 0, {0} };
- global RectSelectTool := { 2, 1, "RectSelect", kDrag, 0, {0} };
- global WandTool := { 3, 1, "HandTool", kClick, 0, {0} };
- #global croptool
- global MagnifyTool := { 5, 1, "MagnifyTool", kClick, 0, {0} };
- global ColorPickup := { 6, 1, "ColorPickup", kClick, 0, {0} };
- global PaintBrush := { 7, 1, "PaintBrush", kMultiDrag, 0, {1,1,0,1} };
- global PencilTool := { 8, 1, "PencilTool", kMultiDrag, 0, {1,1,1,1} };
- global Eraser := { 9, 1, "Eraser", kMultiDrag, 0, {0} };
- global BlendTool := {10, 1, "BlendTool", kMultiDrag, 0, {0} };
- global AirBrush := {11, 1, "AirBrush", kMultiDrag, 0, {1,1,0,1} };
- global SmudgeTool := {12, 1, "Smudge", kMultiDrag, 0, {0} };
- global PastelTool := {13, 1, "PastelTool", kMultiDrag, 0, {1,1,0,1} };
- global CharcoalTool := {14, 1, "CharcoalTool", kMultiDrag, 0, {1,1,0,1} };
- #global rubberstamp
- global LineTool := {16, 1, "Line", kDrag, 1, {1,0,1,0} };
- #global BezierTool
- #note chartool is really a double click and needs to be implemented as such!!
- global Chartool := {18, 1, "Chartool", kClick, 0, {1,0,0,1} };
- global RectTool := {19, 1, "Rectangle", kDragClick, 1, {1,0,0,1} };
- global OvalTool := {20, 1, "OvalTool", kDragClick, 1, {1,0,0,1} };
- global FillTool := {21, 1, "FillTool", kClick, 0, {1,0,0,1} };
- #global PolyTool
- global FreeTool := {23, 1, "FreeTool", kMultiDrag, 1, {1,0,0,1} };
- global RegPolyTool := {24, 1, "RegPolyTool", kDragClick, 0, {1,0,0,1} };
-
-
- global gToolList:={ FreeSelectTool,
- RectSelectTool,
- WandTool,
- ColorPickup,
- PaintBrush,
- PencilTool,
- Eraser,
- BlendTool,
- AirBrush,
- SmudgeTool,
- PastelTool,
- CharcoalTool,
- LineTool,
- CharTool,
- RectTool,
- OvalTool,
- FillTool,
- FreeTool,
- RegPolyTool
- };
-
- global gDocumentWindow := [window c:True g:True z:True]!;
-
- #gMagnifyTool is defined just not in the gToolList
-
- #global gToolList:={FreeTool,RectTool,LineTool, RegPolyTool};
-
- ### font characteristic lists
- # gFontList must be set up in same order as popup in app - don't use list defined in Globals.lib
- global gFontList := {'Chicago','Courier','Geneva','Helvetica','Monaco', 'New York',
- 'Palatino','Symbol','Times'};
- global gFontSizeList := {'9','10','12','14','18', '24','27','30','36','42','48'};
- global gFontStyleList := {'Bold','Italic','Outline', 'Underline','Shadow'};
-
-
- ### Name of the Plain (style) menu item ####
- global gPlainStyle := "Plain"; # Plain-Style menu item
-
- ### How to get to the next line
- global gNextlineMethod := 1;
- ### 1 - ReturnKey, 2 - EnterKey, 3 - DownArrow Key, 4 - TabKey, {} - Move/Click, {'Untitled'} - Move relative to the window titled 'Untitled' /Click
-
- ### Does moving to the next line clear all font info
- global gNextlineClearsFontSettings := 0;
-
- global gCurFontNo := 1; #Initializes starting font for SetPPPFonts
- global gSetFont := Task SetPPPFonts; #overrides SetFont Task Requires VU 2.0
- global gSetSize := Task SetPPPSize; #overrides SetSize Task Requires VU 2.0
- global gSetStyle := Task SetPPPStyle; #overrides SetStyle Task Requires VU 2.0
- global gNextline := Task PPPNextline; # overrides Nextline Requires VU 2.0
- global gReportSelectedMenuItems := Task PPPReportSelected; # overrides ReportSelectedMenuItems Task
-
- end; # InitAppGlobals
-
- #########################################################################
- # SetPPPFonts(pMyFont)
- #========================================================================
- # Author: GS
- # Description: Sets the currently selected font to <pMyFont>
- # Parameters: pMyFont - Name of the font.
- # Returns: Nada
- # Examples: SetPPPFonts('Geneva');
- # Assumptions: That gFontList is correct and the fonts are in the list in
- # the order that they appear in the application
- # InitFonts was called before the 1st time SetPPPFont was called
- #========================================================================
- # History:
- #
- #########################################################################
- task SetPPPFonts(pMyFont, pMyObjectNum)
- begin #figure out how much to move
- global gCurFontNo;
- toMov := 0;
- needToMov := 0;
- myFontNo := 0;
-
- for i := 1 to card(global gFontList)
- begin
- if gFontList[i] = pMyFont #Which font number is it?
- begin
- myFontNo := i;
- end;
-
- end;
- toMov := myFontNo - gCurFontNo;
- vMov := 17; #Each item in this list is {vMove} pixels apart
- needToMov := vMov * toMov; #How far to we need to move
- moveRelativeToWindow(88,25,'TextDialog'); #Move to the popPoint
- pressMouse;
- move r:{0,needToMov}; #Select the font
- releaseMouse;
-
- gCurFontNo := myFontNo;
-
- # println "this is the pMyFont - ", pMyFont;
- return(pMyFont);
- end;
-
- #########################################################################
- # SetPPPStyle(pMyStyle)
- #========================================================================
- # Author: GS
- # Description: Sets the currently selected PPP font style to <pMyStyle>
- # Parameters: pMyStyle - Name of the Style.
- # Returns: Nada
- # Examples: SetStyle('Bold');
- # Assumptions: None
- #========================================================================
- # History:
- #
- #########################################################################
- task SetPPPStyle(pMyStyle, pMyObjectNum)
- begin
- returnVal := 0;
- if pMyStyle = global gPlainStyle
- begin
- y:= 0;
- x := collect[checkbox s:{1,1}]!;
- if(x)
- begin
- for each item in x
- begin
- y := y +1;
- myCheckBox := x[y].t;
- SelectCheckBox(myCheckBox);
- end;
- returnVal := gPlainStyle;
- end;
- end;
- else
- returnVal := SelectCheckBox(pMyStyle);
- return(returnVal);
- end; # SetStyle()
-
- #########################################################################
- # SetPPPSize(pMySize)
- #========================================================================
- # Author: GS
- # Description: Sets the currently selected font size to <pMySize>
- # Parameters: pMySize - Name of the size.
- # Returns: Nada
- # Examples: SetSize('10');
- # Assumptions: None
- #========================================================================
- # History:
- #
- #########################################################################
- task SetPPPSize(pMySize, pMyObjectNum)
- begin
- MoveRelativeToWindow(58,49,'TextDialog',0);
- doubleClick; #select size text box
- TypeStr(pMySize);
- type k:{tabKey}; #Reselect main text box
- type k:{tabKey};
- return(pMySize);
- end; # SetSize()
-
- #########################################################################
- # PPPNextline()
- #========================================================================
- # Author: GS
- # Description: Prepares application to accept the next line of text
- # Parameters: None
- # Returns: Nix
- # Examples: PPPNextline();
- # Assumptions:
- #========================================================================
- # History:
- #
- #########################################################################
- task PPPNextline()
- begin
- SpecialKey(EnterKey, "EnterKey"); # Clear the old dialog
- click;
- MoveRelativeToWindow(,,global gDocumentWindow); # Move to a random point frontmost window
- pressmouse;
- wait(1);
- releasemouse;
-
- end; # PPPNextline()
-
- #########################################################################
- # PPPReportSelected()
- #========================================================================
- # Author: ML
- # Description: Custom task to report font size and styles choosen
- # Parameters: None
- # Returns: Nix
- # Examples: PPPReportSelected();
- # Assumptions:
- #========================================================================
- # History:
- #
- #########################################################################
- task PPPReportSelected()
- begin
- # Need to add task to built list here!
- end; # PPPReportSelected()
-
- #########################################################################
- # PPProModifyDocument()
- #========================================================================
- # Author: ML
- # Description: Modify PPPro Document
- # Parameters: None
- # Returns: Nothing
- # Examples: PPProModifyDocument();
- # Assumptions: None
- # Applications: PPPro
- #========================================================================
- # History:
- #
- #########################################################################
- task PPProModifyDocument()
- begin
- logstr("Modifying the '{global gapptitle}' document...");
- return(Scrapbook(global kScrapPict));
- end;
-
- #########################################################################
- # PPProScrapText()
- #========================================================================
- # Author: ML
- # Description: Test PPPro scraptext
- # Parameters: None
- # Returns: Nothing
- # Examples: PPProScrapText();
- # Assumptions: None
- # Applications: PPPro
- #========================================================================
- # History:
- #
- #########################################################################
- task PPProScrapText()
- begin
- MoveRelativeToWindow(71,5,1,2); # show all tools in the tool pallete
- Scrapbook(global kScraptext,,0);
- PPProSetupDoText(); # set up to handle text
- KeyEq('v'); # VU thinks 'Paste' menuitem is disabled
- SpecialKey(EnterKey, "EnterKey"); # Clear text dialog
- end;
-
- #########################################################################
- # PPProSetupDoText()
- #========================================================================
- # Author: ML
- # Description: Set up for DoText()
- # Parameters: None
- # Returns: Nothing
- # Examples: PPProSetupDoText();
- # Assumptions: None
- # Applications: PPPro
- #========================================================================
- # History:
- #
- #########################################################################
- task PPProSetupDoText()
- begin
- logstr("setting up for text...");
- SetTool(global CharTool); # Select the tool
- MoveRelativeToWindow(,,global gDocumentWindow,2);# Move to a random point frontmost window
- pressmouse;
- wait(1);
- releasemouse;
- end;
- #########################################################################
- # PPProClearDoText()
- #========================================================================
- # Author: ML
- # Description: clears DoText()
- # Parameters: None
- # Returns: Nothing
- # Examples: PPProClearDoText();
- # Assumptions: None
- # Applications: PPPro
- #========================================================================
- # History:
- #
- #########################################################################
- task PPProClearDoText()
- begin
- logstr("clearing text entry...");
- SpecialKey(DeleteKey, "Delete Key"); # Delete leftover text in dialog
- SpecialKey(EnterKey, "EnterKey"); # Close text dialog
- end;
-
- ################################################################################
- #################### Main script ####################
- ################################################################################
- script PPPro (ScriptLevel:= -1)
- begin
- InitGlobals(ScriptLevel); # initialize your general globals
- InitDraw();
- InitFonts();
- Global gApptitle := "PixelPaint Pro";
- global gAppVersion := '2'; # version of app you will be running
- global gFileName := "@!@-{gBuildVers}-{gAppTitle}"; # This is used in SaveAs when saving files
- Global gLaunchReqs := {'fpu'}; # required to run app
- SuiteStart('PixelPaintPro.vu'); # begin a new test suite
- if LaunchTwitch("{gAppTitle}",gAliasDirectory) # launch or twitch to your app
- begin
- global gModifyDocument := task PPProModifyDocument; # define app specific task
- global gCustomScrapText := task PPProScrapText; # define app specific task
- global gSetupDoText := task PPProSetupDoText; # define app specific task
- global gReportSelectedMenuItems := task PPPReportSelected;
- global gCustomRetrievedDoc := [window t:/@•@-{gBuildVers}≈/]; # Note:'PPPro substitutes '•' for '!' in window title"
- global gClearDoText := task PPProClearDoText;
- InitAppGlobals(); # init app specific globals
- (*
- *)
- DoSetUpApp(0,-1,,1,1,1,1);
- DoDraw();
- DoText();
- DoWindow();
- DoCloseApp(1,4);
- LogStr("############################# LIMITATIONS: ############################");
- LogStr("NOTE: No TCS's for DoText are generated because PPPro used custom font
- tasks to handle it's font dialog.");
- end; # if LaunchTwitch("{gAppTitle}",gAliasDirectory)
- SuiteEnd();
- end; # script PPPro
-
- ### What's Needed
- # 1) Set up TCS's for custom tasks used in Dotext - SetPPPFonts, SetPPPSize, SetPPPStyle,
- # PPPNextline, PPPReportSelected